package practice;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * 集群负载统计
 */
public class ClusterLoadCount {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int num = Integer.parseInt(sc.nextLine());
            Map<String, Integer> countMap = new HashMap<>(num);
            for (int i = 0; i < num; i++) {
                String path = sc.nextLine();
                countMap.put(path,countMap.getOrDefault(path,0)+1);
            }
            String[] query = sc.nextLine().split(" ");
            int matchLevel = Integer.parseInt(query[0]);
            String matchStr = query[1];

            int count = 0;
            for (Map.Entry<String,Integer> entry: countMap.entrySet()) {
                String[] strs = entry.getKey().split("/");
                for (int i = 0; i < strs.length; i++) {
                    if (i == matchLevel && strs[i].equals(matchStr)) {
                        count++;
                        break;
                    }
                }
            }
            System.out.println(count);
        }
    }
}
